<template>
	<view class="content">
		<view v-if="content">
			<view class="news-title">{{title}}</view>
			<img :src="newsImageUrl" alt="" style="width:100%">
			<u-parse :content="content"></u-parse>
		</view>
		<mescroll-empty v-else></mescroll-empty>
	</view>
</template>

<script>
import MescrollEmpty from '@/components/mescroll-uni/components/mescroll-empty.vue';

import uParse from '@/components/u-parse/u-parse.vue'
export default {
	components: {
		MescrollEmpty
	},
	data() {
		return {
			title: "",
			content: "",
			newsImageUrl:""
		}
	},
	onLoad(options) {
		options.id && this.getDetails(options.id);
	},
	methods: {
		async getDetails(id) {
			let res = await uniCloud.callFunction({
				name: 'newsDetails',
				data: {
					id: id
				}
			});
			console.log("####"+res);
			const data = res.result.data;
			if (data.length) {
				this.title = data[0].title;
				this.content = data[0].content;
				console.log(this.content)
				this.newsImageUrl = data[0].cover.url;
			}
		}
	}
}
</script>

<style lang="scss" scope>
	.news-title{
		font-weight: 700;
		font-size: 42rpx;
		text-indent: 0em;
	}
.content {

	padding: 33rpx;
	color: $u-content-color;
	font-size: 32rpx;
	line-height: 1.8;
	 text-indent: 2em; 

	.article-title {
		font-size: 48rpx;
		margin-bottom: 31rpx;
	}

	p {
		color: $u-tips-color;
	}
}
</style>
